//
//  UserAbstractView.m
//  LXFCommon
//
//  Created by lixfey on 2019/3/19.
//  Copyright © 2019 lixfey. All rights reserved.
//

#import "UserAbstractView.h"

@interface UserAbstractView ()
@property(nonatomic, strong) UserAbstractBaseView *baseView;
@end


@implementation UserAbstractView



- (void)addSubviews {
    [self addSubview:self.baseView];
    [self addConstraints];
    __weak typeof(self) weakSelf= self;
    self.baseView.AbstractBaseViewClickBlock = ^(NSUInteger index) {
        if ([weakSelf.delegate respondsToSelector:@selector(didselectBaseView:selectIndex:indexPath:)]) {
            [weakSelf.delegate didselectBaseView:weakSelf selectIndex:index indexPath:weakSelf.indexPath];
        }
    };
}

- (void)addConstraints {
    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.offset(0);
        make.height.equalTo(self);
    }];
}

- (instancetype)init {
    self = [super init];
    if (self) {
        [self addSubviews];
    }

    return self;
}


- (void)setBaseModel:(AbstractBaseModel *)baseModel {
    _baseModel = baseModel;
    self.baseView.model = baseModel;
}


- (UserAbstractBaseView *)baseView {
    if (!_baseView) {
        _baseView = [UserAbstractBaseView new];
    }
    return _baseView;
}


@end
